﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentNHibernate.Automapping.Alterations;
using FluentNHibernate.Automapping;

namespace Domain.Model.Mapping.Overrides
{
    public class SubprojectMappingOverride : IAutoMappingOverride<Subproject>
    {
        public void Override(AutoMapping<Subproject> mapping)
        {
            mapping.References<Project>(x => x.Project)
                .Column("ProjectId");

            mapping.HasMany<SubprojectTask>(x => x.Tasks)
                .Cascade.All()
                .Inverse()
                .Not.LazyLoad()
                .AsBag();

            mapping.HasMany<SubprojectDetail>(x => x.Details)
                .Cascade.All()
                .Inverse()
                .Not.LazyLoad()
                .AsBag();

            mapping.References<SubprojectStatus>(x => x.Status)
                .Cascade.All()
                .Not.LazyLoad();
        }
    }
}